 function downloadrul(id){
        // id = '5255987'
        // var url =  "https://api.imjad.cn/cloudmusic/?type=url&id=" +  id
        var url = "https://api.a632079.me/nm/url/" + id
        return axios.get(url)
    }

    function downloadlry(id){
        // var url =  "https://api.imjad.cn/cloudmusic/?type=lyric&id=" +  id
        var url = "https://api.a632079.me/nm/url/" + id
        return(axios.get(url))
    }


    function downloadname(id){
        // var url =  "https://api.imjad.cn/cloudmusic/?type=detail&id=" +  id
        var url = "https://api.a632079.me/nm/detail/" + id
        return(axios.get(url))

    }

    async function downloadplaylist(id){
        // var url =  "https://api.imjad.cn/cloudmusic/?type=playlist&id=" +  id;
        var url = "https://api.a632079.me/nm/playlist/" + id;
        res = await  axios.get(url);
        res = res.data ;

        id_list=[]

        for (ii in res.playlist.tracks){
            id_list.push(res.playlist.tracks[ii].id.toString());
        }
        return(id_list) ;
    }
    async function loadplaylist(arr){
        // '2215356763'
        // var arr = downloadplaylist(playlistid)
        // var aa = 'https://api.a632079.me/nm/redirect/music/'
        // var aa = 'https://api.imjad.cn/cloudmusic/?type=url&id=21674656'

        details = []
        lrcs =[]
        urls = []

        for(i in arr){

            var detail = downloadname(arr[i]);
            var lrc = downloadlry(arr[i]);
            var url = downloadrul(arr[i])

            // detail = await detail;
            // lrc = await lrc;
            // url = await url;

            details.push(detail);
            lrcs.push(lrc);
            urls.push(url);
        }

        details = await Promise.all(details)
        lrcs = await Promise.all(lrcs)
        urls = await Promise.all(urls)

        res = []

        len = urls.length
        for(let i=0;i<len;i++){
            try{
                if("lyric" in lrcs[i].data.lrc == false){
                    lrc = 'None';
                }
                else{
                    lrc = lrcs[i].data.lrc.lyric;
                }

            }
            catch (e) {
                lrc='None'
            }
            if (urls[i].data.data[0].url == null){
                continue
            }

            tmp = {
                name:details[i].data.songs[0].name,
                artist: details[i].data.songs[0].ar[0].name,
                url: urls[i].data.data[0].url,
                cover:  details[i].data.songs[0].al.picUrl,
                lrc: lrc
            }
            res.push(tmp)
        }
        return(res)
    }


    async function showplaylist(){
        var input = document.getElementById("subdiv2");
        var playlist =   downloadplaylist(input.textContent);
        playlist = await playlist;
        var first_song = await  loadplaylist([playlist[0]]) ;
        // console.log(first_song)
        var ap = new APlayer({
            container: document.getElementById('player1'),
            lrcType: 1,
            fixed: false,
            audio: first_song,
        });
        ap.play();
        var rest_songs =  await  loadplaylist(playlist.slice(1)) ;
        // console.log(rest_songs)
        ap.list.add(rest_songs);

    };
    showplaylist();